// 使用axios发起网络请求
import axios from 'axios'
import { reactive, ref } from 'vue'
export default function <T>(url: string) {
    // 加载的状态
    const loading = ref(true)
    const data = ref<T | null>(null)
    const err = ref('')
    axios.get(url).then(res => {
        loading.value = false
        data.value = res.data || "数据"
    }).catch(err => {
        loading.value = false
        err.value = err.message || '未知错误'

    })
    return { loading, data, err }

}